 <?php
session_start();
set_include_path('.'.PATH_SEPARATOR.'/');
include './functions.php';
spl_autoload_register('generic_autoload');

// on instancie la connexion à la base
Controller_Template::$db = new MyPDO();

//preg_match('#^'.$_SERVER['HTTP_ROOT'].'(?:([a-z]+)/)?#', $_SERVER['REQUEST_URI'], $match);

// Début de la tamporisation de sortie
// ob_start();


if(empty($_GET['choix'])){
	$controller = Controller_Index::getInstance('Index');
	$controller->index();
} else {
	switch($_GET['choix']){
		case 'inscription':
			$controller = Controller_Index::getInstance('Index');
			$controller->inscription();
			break;
		case 'connexion':
			$controller = Controller_Connection::getInstance('Connection');
			$controller->connection();
			break;
                case 'terrain':
                        $controller = Controller_Index::getInstance('Terrain');
                        $controller->displayFull($_GET['idTerrain']);
                        break;
                case 'deconnection':
                        if(!empty($_SESSION['login']) && isset($_SESSION['login'])){
                            $controller = Controller_Connection::getInstance('Connection');
                            $controller->deconnection();
                        } else {
                            Controller_Error::sessionError();
                        }
                        break;
		default:
                        Controller_Error::documentNotFound();
	}
}
// $contenu = ob_get_clean();

?>